how to monitor thread status in java application